<template>
	<view @click="open">
		<!-- 基础模式 -->
		<view class="list-card" v-if="item.mode === 'base'">
			<view class="list-card-image">
				<image :src="item.cover[0]" mode="aspectFill"></image>
			</view>
			<view class="list-card-content">
				<view class="list-card-content__title">
					<text>
						{{ item.title }}
					</text>
					<likes :types="types" :item="item"></likes>
				</view>
				<view class="list-card-content__des">
					<view class="list-card-content__des-label">
						<view class="list-card-content__des-label-item">
							{{ item.classify}}
						</view>
					</view>
					<view class="list-card-content__des-browse">
						人浏览
					</view>
				</view>
			</view>
		</view>
		
		<!-- 多图模式 -->
		<view class="list-card mode-column" v-if="item.mode === 'column'">
			<view class="list-card-content">
				<view class="list-card-content__title">
					<text>
						{{ item.title }}
					</text>
					<likes :types="types" :item="item"></likes>
				</view>
				<view class="list-card-image">
					<view class="list-card-image__itme" v-if="index < 3"  v-for="(item, index) in item.cover" :key="index">
						<image :src="item" mode="aspectFill"></image>
					</view>
				</view>
				<view class="list-card-content__des">
					<view class="list-card-content__des-label">
						<view class="list-card-content__des-label-item">
							{{ item.classify}}
						</view>
					</view>
					<view class="list-card-content__des-browse">
						{{item.browse_count}}人浏览
					</view>
				</view>
			</view>
		</view>
		<!-- 大图模式 -->
		<view class="list-card mode-image" v-if="item.mode === 'image'">
			<view class="list-card-image">
				<image :src="item.cover[0]" mode="aspectFill"></image>
			</view>
			<view class="list-card-content">
				<view class="list-card-content__title">
					<text>
						{{ item.title }}
					</text>
					<likes :types="types" :item="item"></likes>
				</view>
				<view class="list-card-content__des">
					<view class="list-card-content__des-label">
						<view class="list-card-content__des-label-item">
							{{ item.classify}}
						</view>
					</view>
					<view class="list-card-content__des-browse">
						{{item.browse_count}}人浏览
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			item: {
				type: Object,
				default: () => {}
			},
			types: {
				type: String,
				defual: ''
			}
		},
		data() {
			return {
				
			}
		},
		methods: {
			open () {
				const { item } = this
				console.log(item);
				this.$emit('click', this.item)
				const params = {
					_id: item._id,
					title: item.title,
					author: item.author,
					create_time: item.create_time,
					thumbs_up_count: item.thumbs_up_count,
					browse_count: item.browse_count
				}
				// console.log(params)
				uni.navigateTo({
					url: '/pages/home-detail/home-detail?params=' + JSON.stringify(params)
				})
			}
		}
	}
</script>

<style lang="scss">
	.list-card {
		display: flex;
		padding: 10px;
		margin: 10px;
		border-radius: 5px;
		box-shadow: 0 0 5px 1px rgba($color: #000000, $alpha: 0.1);
		box-sizing: border-box;
		.list-card-image {
			flex-shrink: 0;
			width: 60px;
			height: 60px;
			border-radius: 5px;
			overflow: hidden;
			image {
				width: 100%;
				height: 100%;
			}
		}
		.list-card-content {
			display: flex;
			flex-direction: column;
			padding-left: 10px;
			justify-content: space-between;
			width: 100%;
			.list-card-content__title {
				padding-right: 30px;
				font-size: 14px;
				font-weight: 400;
				line-height: 1.2;
				position: relative;
				text {
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient:vertical;
				}
			}
			.list-card-content__des {
				display: flex;
				justify-content: space-between;
				font-size: 12px;
				.list-card-content__des-label {
					display: flex;
					.list-card-content__des-label-item {
						padding: 0 5px;
						margin-right: 5px;
						border-radius: 15px;
						border: 1px $mk-base-color solid;
						color: $mk-base-color;
					}
				}
				.list-card-content__des-browse {
					color: #999999;
					line-height: 1.5;
				}
			}
		}
		&.mode-column {
			.list-card-content {
				width: 100%;
				padding-left: 0;
			}
			.list-card-image {
				display: flex;
				margin-top: 10px;
				width: 100%;
				height: 70px;
				.list-card-image__itme {
					margin-left: 10px;
					width: 100%;
					height: 100%;
					border-radius: 5px;
					overflow: hidden;
					&:first-child {
						margin-left: 0;
					}
					image {
						width: 100%;
						height: 100%;
					}
				}
			}
			.list-card-content__des  {
				margin-top: 10px;
			}
		}
		&.mode-image {
			flex-direction: column;
			.list-card-image {
				width: 100%;
				height: 100px;
			}
			.list-card-content {
				padding-left: 0;
				margin-top: 10px;
				.list-card-content__des {
					display: flex;
					align-items: center;
					margin-top: 10px;
				}
			}
		}
	}
</style>
